package com.shujia.spark.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo5Action {
  def main(args: Array[String]): Unit = {

    val conf = new SparkConf()

    conf.setAppName("action")

    conf.setMaster("local")

    val sc = new SparkContext(conf)


    val studentRDD: RDD[String] = sc.textFile("data/students.txt")

    /**
      * 转换算子是懒执行，需要一个action算子触发执行
      *
      */

    val newDD: RDD[String] = studentRDD.map(line => {
      println("map:" + line)
      line
    })

    /**
      * action算子出发2任务的执行，每一个action算子都会触发一个job
      *
      */

    newDD.foreach(println)
    newDD.foreach(println)

    while (true) {

    }

  }

}
